package workers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import messaging.IMessagingHandler;
import messaging.JMSMessagingConstants;
import messaging.SoftwareDevelopmentMessagingHandler;
import model.Software;
import workerUIs.StepFrame;
import workflow.step.ArchitectureDesignStep;

/**
 * ArchitectureStepWorker class.
 * 
 * @author Mark Czotter
 * @author Miklos Szennai
 * 
 */
public class ArchitectureStepWorker extends AbstractStepSwingWorker {
	
	public ArchitectureStepWorker(StepFrame frame, IMessagingHandler<Software> messagingHandler) {
		super(frame, messagingHandler);
	}
	
	@Override
	protected void doStep(Software software) {
		new ArchitectureDesignStep().doStep(software);
	}
	
	public static void main(String[] args) {
		Logger logger = Logger.getLogger(ArchitectureStepWorker.class.getCanonicalName());
		try {
			final StepFrame architectureFrame = new StepFrame("Step2: Architecure Design", 400, 200);
			List<String> archInputQueues = new ArrayList<String>();
			archInputQueues.add(JMSMessagingConstants.SPEC_OUTPUT_ARCH_INPUT);
			List<String> archOutputQueues = new ArrayList<String>();
			archOutputQueues.add(JMSMessagingConstants.ARCH_OUTPUT_IMPL_INPUT);
			archOutputQueues.add(JMSMessagingConstants.ARCH_OUTPUT_UI_INPUT);
			final IMessagingHandler<Software> messagingHandler = new SoftwareDevelopmentMessagingHandler(architectureFrame, archInputQueues, archOutputQueues);
			architectureFrame.getNextButton().addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					new ArchitectureStepWorker(architectureFrame, messagingHandler).execute();
				}
			});
		}
		catch (Exception e)
		{
			logger.log(Level.SEVERE, "Error during initialization: ", e);
		}
	}

}
